package com.bestcem.xm.user.mq.sender;

import com.bestcem.xm.user.mq.message.organization.OrgCreateMessage;
import lombok.extern.slf4j.Slf4j;

import java.util.Date;

/**
 * 公司相关消息发送
 *
 * @author qiongyu.cui <qiongyu.cui@idiaoyan.com>
 * @version v1.0
 * @date 2022/3/9 18:30
 */
@Slf4j
//@Component("organizationMessageSender")
@Deprecated
public class OrganizationMessageSender {
    //@Resource
    //private RabbitMessageSender rabbitMessageSender;
    //@Resource
    //private RabbitMqConstantConfig rabbitMqConstantConfig;

    /**
     * @param data      消息数据
     * @param delayDate 延时时间
     * @param msg       任务内容
     * @return void
     * @author Linzhijian <zhijian.lin@idiaoyan.com>
     * @date 2022/03/11 16:47
     */
    public void sendDelayMq(Object data, Date delayDate, String msg) {
        if (log.isInfoEnabled()) {
            log.info("[USER] 用户中心 {} 发送提醒消息延时MQ; {},{}", msg, data, delayDate);
        }
        try {
            //rabbitMessageSender.sendDelayMsg(rabbitMqConstantConfig.getAppBpUserDelayExchange(), rabbitMqConstantConfig.getAppBpUserDelayRoutingKey(),
            //        UserTopics.USER_EMAIL_SMS_TOPIC, data, delayDate);
        } catch (Exception e) {
            log.error("[USER] 用户中心 {} 延迟消息发送失败; {},{}", msg, data, delayDate, e);
        }
    }

    /**
     * 初始化创建公司
     *
     * @return void
     * @author panyun <yun.pan@idiaoyan.com>
     * @date 2022/3/23 20:49
     */
    public void userOrgCreate(String orgId) {
        OrgCreateMessage message = new OrgCreateMessage(orgId);
        //try {
        //    // fanout模式直接发送给python
        //    rabbitMessageSender.sendMsg(rabbitMqConstantConfig.getAppFanoutExchange(), RoutingKeys.APP_FANOUT,
        //            OrganizationTopics.ORG_CREATED, dto);
        //
        //    // topic模式发送给java
        //    rabbitMessageSender.sendMsg(rabbitMqConstantConfig.getAppBpDirectExchange(), rabbitMqConstantConfig.getAppBpRoutingKey(),
        //            OrganizationTopics.ORG_CREATED, dto);
        //
        //    if (log.isInfoEnabled()) {
        //        log.info("[User.Organization] 发送mq消息成功, EXCHANGE_NAME={}, ROUTING_KEY={}, topic={}, mqMsg={}",
        //                rabbitMqConstantConfig.getAppFanoutExchange(), rabbitMqConstantConfig.getAppBpRoutingKey(),
        //                OrganizationTopics.ORG_CREATED, dto);
        //    }
        //} catch (Exception e) {
        //    log.error("[User.Organization] 发送mq消息失败, EXCHANGE_NAME={}, ROUTING_KEY={}, topic={}, mqMsg={}",
        //            rabbitMqConstantConfig.getAppFanoutExchange(), rabbitMqConstantConfig.getAppBpRoutingKey(),
        //            OrganizationTopics.ORG_CREATED, dto);
        //    log.error("[User.Organization] 发送mq消息失败. e", e);
        //}
    }

    /**
     * 创建免费版公司发送消息
     *
     * @param orgId 公司id
     * @author wangyunyun <yunyun.wang@idiaoyan.com>
     * @date 2022/4/29 09:04
     */
    public void userFreeOrgCreate(String orgId) {
        //FreeOrgCreateMessage dto = new FreeOrgCreateMessage(orgId);
        //try {
        //    // fanout模式直接发送给python
        //    rabbitMessageSender.sendMsg(rabbitMqConstantConfig.getAppFanoutExchange(), RoutingKeys.APP_FANOUT,
        //            OrganizationTopics.FREE_ORG_CREATED, dto);
        //
        //    // topic模式发送给java
        //    rabbitMessageSender.sendMsg(rabbitMqConstantConfig.getAppBpDirectExchange(), rabbitMqConstantConfig.getAppBpRoutingKey(),
        //            OrganizationTopics.FREE_ORG_CREATED, dto);
        //
        //    if (log.isInfoEnabled()) {
        //        log.info("[User.Organization] 发送mq消息成功, EXCHANGE_NAME={}, ROUTING_KEY={}, topic={}, mqMsg={}",
        //                rabbitMqConstantConfig.getAppFanoutExchange(), rabbitMqConstantConfig.getAppBpRoutingKey(),
        //                OrganizationTopics.FREE_ORG_CREATED, dto);
        //    }
        //} catch (Exception e) {
        //    log.error("[User.Organization] 发送mq消息失败, EXCHANGE_NAME={}, ROUTING_KEY={}, topic={}, mqMsg={}",
        //            rabbitMqConstantConfig.getAppFanoutExchange(), rabbitMqConstantConfig.getAppBpRoutingKey(),
        //            OrganizationTopics.FREE_ORG_CREATED, dto);
        //    log.error("[User.Organization] 发送mq消息失败", e);
        //}
    }


    /**
     * 套餐降级
     *
     * @param orgId
     * @param oldPackId
     * @param newPackId
     * @return void
     * @author Linzhijian <zhijian.lin@idiaoyan.com>
     * @date 2022/05/05 10:43
     */
    public void orgPackUpdate(String orgId, String oldPackId, String newPackId) {
        //OrgPackUpdateMessage orgPackUpdateMessage = new OrgPackUpdateMessage(orgId, oldPackId, newPackId);
        //try {
        //    // fanout模式直接发送给java
        //    rabbitMessageSender.sendMsg(rabbitMqConstantConfig.getAppBpDirectExchange(), rabbitMqConstantConfig.getAppBpRoutingKey(),
        //            OrganizationTopics.ORG_PACKAGE_UPDATE, orgPackUpdateMessage);
        //
        //    if (log.isInfoEnabled()) {
        //        log.info("[User.Organization] 发送mq消息成功, EXCHANGE_NAME={}, ROUTING_KEY={}, topic={}, mqMsg={}",
        //                rabbitMqConstantConfig.getAppBpDirectExchange(), rabbitMqConstantConfig.getAppBpRoutingKey(),
        //                OrganizationTopics.ORG_PACKAGE_UPDATE, orgPackUpdateMessage);
        //    }
        //} catch (Exception e) {
        //    log.error("[User.Organization] 发送mq消息失败, EXCHANGE_NAME={}, ROUTING_KEY={}, topic={}, mqMsg={}",
        //            rabbitMqConstantConfig.getAppFanoutExchange(), rabbitMqConstantConfig.getAppBpRoutingKey(),
        //            OrganizationTopics.ORG_PACKAGE_UPDATE, orgPackUpdateMessage);
        //}
    }

    /**
     * 公司信息变更
     *
     * @param orgId   公司id
     * @param orgName 公司名称
     * @param orgCode 公司编码
     * @author cuiqiongyu <qiongyu.cui@idiaoyan.cn>
     * @date 2022/07/07 11:28
     */
    public void orgInfoUpdate(String orgId, String orgName, String orgCode) {
        //OrgInfoUpdateMessage orgInfoUpdateMessage = new OrgInfoUpdateMessage(orgId, orgName, orgCode);
        //try {
        //    // fanout模式直接发送给java
        //    rabbitMessageSender.sendMsg(rabbitMqConstantConfig.getAppBpDirectExchange(), rabbitMqConstantConfig.getAppBpRoutingKey(),
        //            OrganizationTopics.USER_ORG_INFO_UPDATE, orgInfoUpdateMessage);
        //
        //    if (log.isInfoEnabled()) {
        //        log.info("[User.Organization] 发送mq消息成功, EXCHANGE_NAME={}, ROUTING_KEY={}, topic={}, mqMsg={}",
        //                rabbitMqConstantConfig.getAppBpDirectExchange(), rabbitMqConstantConfig.getAppBpRoutingKey(),
        //                OrganizationTopics.USER_ORG_INFO_UPDATE, orgInfoUpdateMessage);
        //    }
        //} catch (Exception e) {
        //    log.error("[User.Organization] 发送mq消息失败, EXCHANGE_NAME={}, ROUTING_KEY={}, topic={}, mqMsg={}",
        //            rabbitMqConstantConfig.getAppFanoutExchange(), rabbitMqConstantConfig.getAppBpRoutingKey(),
        //            OrganizationTopics.USER_ORG_INFO_UPDATE, orgInfoUpdateMessage);
        //}
    }

}




